﻿namespace XDCCManager.Model.Servers
{
	public class ServerAddress : BaseModel, System.ICloneable
	{
		private string hostname;

		public string Hostname
		{
			get { return hostname; }
			set { if (hostname != value) { hostname = value; OnPropertyChanged("Hostname"); } }
		}

		private ushort port = 6667;

		public ushort Port
		{
			get { return port; }
			set { if (port != value) { port = value; OnPropertyChanged("Port"); } }
		}

		private bool ssl;

		public bool Ssl
		{
			get { return ssl; }
			set { if (ssl != value) { ssl = value; OnPropertyChanged("Ssl"); } }
		}


		#region ICloneable Members

		public object Clone()
		{
			return new ServerAddress()
			{
				Hostname = Hostname,
				Port = Port,
				Ssl = Ssl
			};
		}

		#endregion

		public override bool Equals(object obj)
		{
			if (base.Equals(obj))
				return true;
			if (!(obj is ServerAddress))
				return false;
			ServerAddress Address = obj as ServerAddress;
			if ((Address.Hostname != Hostname) ||
				(Address.Port != Port) ||
				(Address.Ssl != Ssl))
				return false;
			return true;
		}

		public override int GetHashCode()
		{
			return Hostname.GetHashCode() ^ Port.GetHashCode() ^ Ssl.GetHashCode();
		}
	}
}
